# Author:wyq
import copy
#三元运算
a,b,c = 1,3,5
d = a if a > b else c
print(d)
# 比特和字符串的转换
msg = "我爱北京天安门"
print(msg.encode("utf-8"))
msgBak = msg.encode("utf-8")
print(msgBak.decode("utf-8"))

#列表

names = ["hhh","dsas","sdasd","dsads","uipkkk","dsads",["lal","hhiip"]]
# 追加
names.append("hielo")
# 插入 没有批量插入
# 插入的角标位置，然后将当前位置的元素整体向后移
names.insert(1,"pppp")
names[0] = "olop"
# 删除
# names.remove("pppp")
# del names[1]
# 默认不输入下表删除的是最后一个
names.pop()
print(names)
print(names[0],names[3])
# 如果要取从角标1到2的元素（包括角标2）要取到2+1角标，起始位包括，结尾不包括。
# 这种动作叫切片
print(names[1:3])
# 取角标最后一位
print(names[-1])
# 省略不写 就是取到最后一位
print(names[-3:])

print(names[:2])

# 获取角标
print(names.index("sdasd"))

print(names.count("dsads"))
#names.reverse()
print(names)
# names.sort()
print(names)
names2 =["1","2","3"]
#names.extend(names2)
# 清空
#names.clear()
# 删除names2
del names2

print(names)

# 浅复制
names3 = names.copy()
names3 = copy.copy(names)
names3 = names[:]
names3 = list(names)
# 以上都是浅copy
names4 = copy.deepcopy(names)
names[2] = "综合"
names[-1][0] ="AAAAA"
print(names)
print(names3)
print(names4)

# 遍历
for i in names4 :
    print(i)
# 跳着切片
print(names[0:-1:2])
# 等同上面的切片
print(names[::2])
